package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.pagehelper.PageInfo;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.CouponConfigService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.vo.request.SelectCouponListVo;
import com.rm.zeyou.vo.response.SelectCouponResponseBaseVo;
import com.rm.zeyou.vo.response.SelectCouponResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 优惠卷配置表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:07
 */
@Api(tags = "优惠券相关")
@RestController
@RequestMapping("/api/coupon")
public class CouponConfigController {

    @Resource
    private CouponConfigService couponService;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation(value = "查询优惠券列表")
    @PostMapping("selectCouponList")
    public ApiRestResponse<PageInfo<SelectCouponResponseVo>> selectCouponList(@RequestBody SelectCouponListVo selectVo) {
        return couponService.selectCouponList(selectVo);
    }

    @ApiOperation(value = "查询新人优惠券列表")
    @PostMapping("selectNewCouponList")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<SelectCouponResponseBaseVo> selectNewCouponList(@RequestBody SelectCouponListVo selectVo) {
        User user = loginUtil.getUser();
        return couponService.selectNewCouponList(user,selectVo);
    }

}
